import axios from 'axios'
import apiUrls from 'common/api-urls'

export function getEmployee(data) {
  return axios.post(apiUrls.getEmployee, {
    ...data
  })
}

export function addEmployee(data) {
  return axios.post(apiUrls.addEmployee, {
    ...data
  })
}

export function updateEmployee(data) {
  return axios.post(apiUrls.updateEmployee, {
    ...data
  })
}

export function getEmployeeInfo(data) {
  data = JSON.parse(JSON.stringify(data))
  return axios.get(`${apiUrls.getEmployeeInfo}/${data.id}`, {
    params: data
  })
}

export function getCourseUserLabels(data) {
  return axios.post(apiUrls.getCourseUserLabels, {
    ...data
  })
}

export function importEmployeeCheck(data) {
  const formData = new FormData()
  formData.append('file', data.file.raw)
  if (data.courseId) {
    formData.append('courseId', data.courseId)
  }
  return axios.post(apiUrls.importEmployeeCheck, formData)
}

export function importEmployeeSave(data) {
  const formData = new FormData()
  formData.append('file', data.file.raw)
  if (data.courseId) {
    formData.append('courseId', data.courseId)
  }
  return axios.post(apiUrls.importEmployeeSave, formData)
}
